package com.daxue.testconsumer.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.BaseClient;
import com.alipay.easysdk.payment.common.models.AlipayTradeCreateResponse;
import com.daxue.global.TestInterface;
import lombok.extern.slf4j.Slf4j;
import org.omg.CORBA.StringHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wangxuedi
 * Date: 2020/4/23 14:46
 * describe:
 */
@Service
@Slf4j
public class TestConsumerService {


    @Reference
    public TestInterface testService;

    public String test01() {
        String s = testService.testMethod();
        return s;
    }

    @Autowired
    BaseClient.Config config;


    public String aliPayService() throws Exception {
        Factory.setOptions(config);
        AlipayTradeCreateResponse response = Factory.Payment.Common().create("Apple iPhone11 128G", "2234567890", "5799.00", "2088002656718920");

        log.info(response.toString());
        if ("10000".equals(response.code)) {
            System.out.println("调用成功");
        } else {
            System.err.println("调用失败，原因：" + response.msg + "，" + response.subMsg);
        }
        return response.toString();
    }

}
